# Maintainer: Jaroslav Lichtblau <svetlemodry@archlinux.org>
# Contributor: Alexander Rødseth <rodseth@gmail.com>

pkgname=nzbget
pkgver=21.1
pkgrel=2
pkgdesc="Download from Usenet using .nzb files"
arch=('loong64' 'x86_64')
url="https://nzbget.net/"
license=('GPL')
depends=('libxml2')
optdepends=('python: to run included scripts'
            'unrar: unpacking archives'
            'p7zip: unpacking archives')
changelog=$pkgname.changelog
source=(https://github.com/nzbget/$pkgname/releases/download/v$pkgver/$pkgname-$pkgver-src.tar.gz
        nzbget_21.1_openssl3_update.patch)
sha256sums=('4e8fc1beb80dc2af2d6a36a33a33f44dedddd4486002c644f4c4793043072025'
            '98a3c9c4206e3797b30d4fea71b3350586bfe0d96ffc5d9ac3de0a86662b06dc')

prepare() {
  cd $pkgname-$pkgver
  # https://github.com/nzbget/nzbget/pull/793
  patch -Np1 -i ../nzbget_21.1_openssl3_update.patch
}

build() {
  cd $pkgname-$pkgver

  ./configure --prefix='/usr' --sbindir='/usr/bin' --enable-parcheck --with-tlslib=OpenSSL
  make
}

package() {
  cd $pkgname-$pkgver

  make DESTDIR="${pkgdir}" install

  install -d "${pkgdir}"/usr/share/$pkgname
  install -m644 -t "${pkgdir}"/usr/share/$pkgname ChangeLog README
}
